package com.frxuexi.lib_base.http

import android.content.Context
import androidx.room.Room
import com.frxuexi.lib_base.room.FocuseDao
import com.frxuexi.lib_base.room.LoginDao
import com.frxuexi.lib_base.room.LoveDao
import com.frxuexi.lib_base.room.ProductDao
import com.frxuexi.lib_base.room.SearchDao
import com.frxuexi.lib_base.room.ShopDataBase
import com.frxuexi.lib_base.room.SignDao
import com.frxuexi.lib_base.room.YueDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
class ProviderFactory {

    @Provides
    @Singleton
    fun getApiService():ApiService=RetrofitUtils.retrofit.create(ApiService::class.java)

    @Provides
    @Singleton
    fun getVideoApiService():VideoApiService=RetrofitUtils.retrofitVideo.create(VideoApiService::class.java)

    @Provides
    @Singleton
    fun initDB(@ApplicationContext context: Context):ShopDataBase{
        return Room.databaseBuilder(context,ShopDataBase::class.java,"shop2307.db").allowMainThreadQueries().build()
    }

    @Provides
    @Singleton
    fun getLoveDao(shopDataBase: ShopDataBase):LoveDao=shopDataBase.getLoveDao()

    @Provides
    @Singleton
    fun getFocuseDao(shopDataBase: ShopDataBase):FocuseDao=shopDataBase.getFocuseDao()

    @Provides
    @Singleton
    fun getloginDao(shopDataBase: ShopDataBase):LoginDao=shopDataBase.getLoginDao()

    @Provides
    @Singleton
    fun getSearchDao(shopDataBase: ShopDataBase):SearchDao=shopDataBase.getSearchDao()

    @Provides
    @Singleton
    fun getProDao(shopDataBase: ShopDataBase):ProductDao=shopDataBase.getProDao()

    @Provides
    @Singleton
    fun getSignDao(shopDataBase: ShopDataBase):SignDao=shopDataBase.getSignDao()

    @Provides
    @Singleton
    fun getYueDao(shopDataBase: ShopDataBase):YueDao=shopDataBase.getYueDao()
}